package com.hzsxy.bighomework.util;

import com.baidubce.BceClientConfiguration;
import com.baidubce.auth.DefaultBceCredentials;
import com.baidubce.services.bos.BosClient;
import com.baidubce.services.bos.BosClientConfiguration;
import com.baidubce.services.doc.DocClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DocFacade {
    @Value("${doc.access.key}")
    private String accessKeyId;

    @Value("${doc.secret.key}")
    private String secretAccessKey;

    @Value("${doc.endpoint}")
    private String docEndpoint;

    @Value("${bos.endpoint}")
    private String bosEndpoint;

    public static String BUCKET = "test100836";

    @Bean
    public DocClient docClient(){
        BceClientConfiguration config = new BceClientConfiguration();
        config.setCredentials(new DefaultBceCredentials(accessKeyId, secretAccessKey));
        config.setEndpoint(docEndpoint);
        return new DocClient(config);
    }

    @Bean
    public BosClient bosClient(){
        BosClientConfiguration config = new BosClientConfiguration();
        config.setCredentials(new DefaultBceCredentials(accessKeyId, secretAccessKey));
        config.setEndpoint(bosEndpoint);
        return new BosClient(config);
    }

}
